package com.itheima.edu.info.manager.service;

import com.itheima.edu.info.manager.dao.TeacherDao;
import com.itheima.edu.info.manager.domain.Teacher;

import java.util.ArrayList;

/**
 * @author Xiao
 * @date 2021/7/19
 */
public class TeacherService {
    private TeacherDao td = new TeacherDao();

    public boolean isExists(String tid) {
        ArrayList<Teacher> list = td.findAllTeacher();
        for (Teacher t : list) {
            if (list.size() > 0 && tid.equals(t.getTid())) {
                return true;
            }
        }
        return false;
    }

    public boolean addTeacher(Teacher t) {
        return td.addTeacher(t);
    }

    public ArrayList<Teacher> findAllTeacher() {
        ArrayList<Teacher> list = td.findAllTeacher();
        for (Teacher t : list) {
            if (list.size() > 0 && t != null) {
                return list;
            }
        }
        return null;
    }

    public boolean deleteTeacher(String tid) {
        return td.deleteTeacher(tid);
    }

    public void updateTeacher(Teacher t, String tid) {
        td.updateTeacher(t, tid);
    }
}
